//
//  OptionalDemo.swift
//  Swift3.0_Study
//
//  Created by chengfeng on 2016/10/14.
//  Copyright © 2016年 zhaochengfeng. All rights reserved.
//

import Cocoa

class OptionalDemo: NSObject {

    func start() -> Void {
        let a: Int? = 123
        let b: Int! = 123
        
        print("a = \(a), b = \(b!)")
        
        let join = Person()
//        join.residence = Resident()
        print(join.residence?.numberOfRoom)
        
        let square: Square? = Square()
        square?.slideLength = 10
        print(square?.slideLength)
    }
    
    class Square {
        var slideLength: Float
        var name: String
        
        init() {
            self.slideLength = 0
            self.name = ""
        }
    }
    
    class Person {
        var residence: Resident?
        var name: String?
    }
    
    class Resident {
        var numberOfRoom = 3
        
    }
}
